/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.sac.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Colao
 */
@Entity
@Table(name = "SAC_DOCUMENTO")
@NamedQueries({@NamedQuery(name = "Documento.findAll", query = "SELECT d FROM Documento d"), @NamedQuery(name = "Documento.findByIdDocumento", query = "SELECT d FROM Documento d WHERE d.idDocumento = :idDocumento"), @NamedQuery(name = "Documento.findByNombre", query = "SELECT d FROM Documento d WHERE d.nombre = :nombre"), @NamedQuery(name = "Documento.findByDescripcion", query = "SELECT d FROM Documento d WHERE d.descripcion = :descripcion")})
public class Documento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID_DOCUMENTO")
    private Long idDocumento;
    @Column(name = "NOMBRE")
    private String nombre;
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @JoinTable(name = "SAC_PRODUCTO_DOCUMENTO", joinColumns = {@JoinColumn(name = "FID_SAC_DOCUMENTO", referencedColumnName = "ID_DOCUMENTO")}, inverseJoinColumns = {@JoinColumn(name = "FID_SAC_SUB_PRODUCTO", referencedColumnName = "ID_SUB_PRODUCTO")})
    @ManyToMany(fetch = FetchType.LAZY)
    private List<SubProducto> subProductoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "documento", fetch = FetchType.LAZY)
    private List<DocumentoPresentado> documentoPresentadoCollection;

    public Documento() {
    }

    public Documento(Long idDocumento) {
        this.idDocumento = idDocumento;
    }

    public Long getIdDocumento() {
        return idDocumento;
    }

    public void setIdDocumento(Long idDocumento) {
        this.idDocumento = idDocumento;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public List<SubProducto> getSubProductoCollection() {
        return subProductoCollection;
    }

    public void setSubProductoCollection(List<SubProducto> subProductoCollection) {
        this.subProductoCollection = subProductoCollection;
    }

    public List<DocumentoPresentado> getDocumentoPresentadoCollection() {
        return documentoPresentadoCollection;
    }

    public void setDocumentoPresentadoCollection(List<DocumentoPresentado> documentoPresentadoCollection) {
        this.documentoPresentadoCollection = documentoPresentadoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDocumento != null ? idDocumento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Documento)) {
            return false;
        }
        Documento other = (Documento) object;
        if ((this.idDocumento == null && other.idDocumento != null) || (this.idDocumento != null && !this.idDocumento.equals(other.idDocumento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.sac.be.Documento[idDocumento=" + idDocumento + "]";
    }

}
